package com.tunan.utils;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.validation.BindingResult;
import org.springframework.validation.FieldError;

public class ValidationUtils {

	public static Map<String, String> convert(BindingResult result){
		Map<String, String> map = new HashMap<String, String>();
		
		List<FieldError> fieldErrors = result.getFieldErrors();
		for(FieldError fieldError : fieldErrors){
			map.put(fieldError.getField(), fieldError.getDefaultMessage());
		}
		
		return map;
	}
}
